package sctu.edu.java.year2016.team04.luoxinghua.day20160605.chapter11_3;

/**
 * Created by 落叶的思恋 on 2016/6/5.
 */

import java.util.Scanner;

public class Computer {
    void Commonmaxfigure(int a, int b) throws CustomException {
        int temp;
        if (a < 0 || b < 0) {
            throw new CustomException(a, b);
        }
        if (a > b)
            temp = b;
        else
            temp = a;
        for (; temp > 0; temp--) {
            if (b % temp == 0 && a % temp == 0)
                break;
        }

        System.out.println(a + "和" + b + "的最大公约数是" + temp );

    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("please enter two numbers");
        int aa = scanner.nextInt();
        int bb = scanner.nextInt();
        Computer computer = new Computer();
        try {
            computer.Commonmaxfigure(aa, bb);
        } catch (CustomException ex) {
            System.out.println(ex);
        }
        System.out.println("over");
    }

}


